package coloring.vertex;

import java.util.UUID;

/**
 * Special vertex for coloring
 * 
 * @author Croaker
 * 
 */
public class Vertex {

	private final String name;
	private int color = 0;
	private boolean checked = false;

	private UUID ID;

	{
		ID = UUID.randomUUID();
	}

	public Vertex(int color, String name) {
		super();
		this.color = color;
		this.name = name;
	}

	public Vertex(String name) {
		super();
		this.name = name;
	}

	public int getColor() {
		return color;
	}

	/**
	 * @return the iD
	 */
	public UUID getID() {
		return ID;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public String getName() {
		return name;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	@Override
	public String toString() {
		return "<" + this.name + ", c" + color + ">";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((ID == null) ? 0 : ID.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Vertex))
			return false;
		Vertex other = (Vertex) obj;
		if (ID == null) {
			if (other.ID != null)
				return false;
		} else if (!ID.equals(other.ID))
			return false;
		return true;
	}

}
